package xiegd.study.lambda;

import lombok.Builder;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: xieguangda
 * @Description:  先按照city排序，再按照county排序
 * @Date: 2023/7/25 9:26
 */
@Slf4j
public class CityTest {

    public static void main(String[] args) {
//        List<City> init = init();
//        System.out.println("我是没排序前的：" + JSONObject.toJSONString(init));
            Integer test = null;
            String test2 = test + "";

        System.out.println("test::" + test2);
//        //排序
//        init.stream().sort(Comparator.comparing(City::getCode)
//                .thenComparing(County::getCode));
    }

    public static List<City> init(){
        City gd = City.builder().code(44).name("广东").build();
        List<County> countyList = new ArrayList<>();
        countyList.add(County.builder().code(4401).name("广州").build());
        countyList.add(County.builder().code(4408).name("湛江").build());
        countyList.add(County.builder().code(4406).name("深圳").build());
        countyList.add(County.builder().code(4403).name("珠海").build());
        gd.setCountyList(countyList);

        City gx = City.builder().code(43).name("广西").build();
        List<County> countyList2 = new ArrayList<>();
        countyList2.add(County.builder().code(4301).name("南宁").build());
        countyList2.add(County.builder().code(4308).name("桂林").build());
        countyList2.add(County.builder().code(4306).name("玉林").build());
        gx.setCountyList(countyList2);


        City yn = City.builder().code(40).name("云南").build();

        List<City> cityList = new ArrayList<>();
        cityList.add(gd);
        cityList.add(gx);
        cityList.add(yn);
        return cityList;
    }

}



@Data
@Builder
class City{
    private Integer code;
    private String name;

    private List<County> countyList;
}
@Data
@Builder
class County{
    private Integer code;

    private String name;
}
